import parameterized_testcase

# First, define your testcase class. Do not derive from TestCase.
class WebsiteTests:
    def setUp(self):
        # Read from some URL based on the configured parameter set.
        datafile, headers = urllib.urlretrieve(self.url)
        with open(datafile, 'r') as f:
            self.data = f.read()

    def test_check_contents(self):
        # Look for a specific string in the data we read.  This target
        # data is also a parameter which is configured later.
        self.assert_(self.target_data in self.data)

# Now define two parameter sets, one for slashdot and one for
# arstechnica. Each specifies a 'url' and 'target_data' member that
# will be attached to the classes generate in the next step.
parameters = {
    # slashdot parameter set
    'slashdot': {
        'url': 'http://www.slashdot.org',
        'target_data': 'Slashdot'
        },
    
    # arstechnica parameter set
    'arstechnica': {
        'url': 'http://www.arstechnica.com',
        'target_data': 'arstechnica',
        }
    }

# We now generate the actual TestCase subclasses.
cases = parameterized_testcase.parameterize(
    cases=[WebsiteTests],
    params=parameters)

# This is just for illustrative purposes.
print(cases)
print([case.url for case in cases])
